package day_2022_9_to_12.Day;

/**
 * @author haomin
 * @date 2022/09/05 22:46
 **/
public class Day3_7_Offer56_SingleNumbers {
    class Solution {
        public int[] singleNumbers(int[] nums) {
            int ret = 0;
            for(int num : nums) ret ^= num;
            int target = 1;
            while((target & ret) == 0) target <<= 1;
            int a = 0, b = 0;
            for(int num : nums){
                if((num & target) == 0) a ^= num;
                else b ^= num;
            }
            return new int[]{a, b};
        }
    }
}